package com.nmsl.inpatientjin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.inpatientjin.domain.JinHospitalizationRegistration;
import com.nmsl.inpatientjin.service.IJinHospitalizationRegistrationService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 住院医生工作台Controller
 * 
 * @author jin
 * @date 2025-02-22
 */
@RestController
@RequestMapping("/inpatientjin/inpatientjin")
public class JinHospitalizationRegistrationController extends BaseController
{
    @Autowired
    private IJinHospitalizationRegistrationService jinHospitalizationRegistrationService;

    /**
     * 查询住院医生工作台列表
     */
    @PreAuthorize("@ss.hasPermi('inpatientjin:inpatientjin:list')")
    @GetMapping("/list")
    public TableDataInfo list(JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        startPage();
        List<JinHospitalizationRegistration> list = jinHospitalizationRegistrationService.selectJinHospitalizationRegistrationList(jinHospitalizationRegistration);
        return getDataTable(list);
    }

    /**
     * 导出住院医生工作台列表
     */
    @PreAuthorize("@ss.hasPermi('inpatientjin:inpatientjin:export')")
    @Log(title = "住院医生工作台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        List<JinHospitalizationRegistration> list = jinHospitalizationRegistrationService.selectJinHospitalizationRegistrationList(jinHospitalizationRegistration);
        ExcelUtil<JinHospitalizationRegistration> util = new ExcelUtil<JinHospitalizationRegistration>(JinHospitalizationRegistration.class);
        util.exportExcel(response, list, "住院医生工作台数据");
    }

    /**
     * 获取住院医生工作台详细信息
     */
    @PreAuthorize("@ss.hasPermi('inpatientjin:inpatientjin:query')")
    @GetMapping(value = "/{registrationId}")
    public AjaxResult getInfo(@PathVariable("registrationId") Long registrationId)
    {
        return success(jinHospitalizationRegistrationService.selectJinHospitalizationRegistrationByRegistrationId(registrationId));
    }

    /**
     * 新增住院医生工作台
     */
    @PreAuthorize("@ss.hasPermi('inpatientjin:inpatientjin:add')")
    @Log(title = "住院医生工作台", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        return toAjax(jinHospitalizationRegistrationService.insertJinHospitalizationRegistration(jinHospitalizationRegistration));
    }

    /**
     * 修改住院医生工作台
     */
    @PreAuthorize("@ss.hasPermi('inpatientjin:inpatientjin:edit')")
    @Log(title = "住院医生工作台", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        return toAjax(jinHospitalizationRegistrationService.updateJinHospitalizationRegistration(jinHospitalizationRegistration));
    }

    /**
     * 删除住院医生工作台
     */
    @PreAuthorize("@ss.hasPermi('inpatientjin:inpatientjin:remove')")
    @Log(title = "住院医生工作台", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registrationIds}")
    public AjaxResult remove(@PathVariable Long[] registrationIds)
    {
        return toAjax(jinHospitalizationRegistrationService.deleteJinHospitalizationRegistrationByRegistrationIds(registrationIds));
    }
}
